//说说模块
import {reqTalkList,addTalkListAxios} from '@/api'
export default {
	namespaced:true,
	state:{
		newList:'',
		talkList: []
	},
	actions:{
		async talkList({commit}){
			let result =await reqTalkList();
			commit("TALKLIST",result)
		},
		addTalkList(context,value){
			if(context.state.newList != ''){
				context.commit('ADDTALKLIST',context.state.newList)
			}else{
				alert('输入不能为空！')
			}
		}
	},
	mutations:{
		TALKLIST(state,talkList){
			state.talkList = talkList.reverse();
		},
		SETNEWLIST:(state,value)=>{
			state.newList= value;
		},
		ADDTALKLIST(state,value){
			addTalkListAxios(value),
			state.newList = '',
			location.reload()
		}
	},
	getters:{
		newList:state => state.newList
	},
}